package com.example.mobilesafe.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.mobilesafe.R;
import com.example.mobilesafe.constant.ConstantValue;
import com.example.mobilesafe.utils.SharedPreferencesUtil;

public class SetupOverActivity extends AppCompatActivity {

    private TextView tv_phone;

    private TextView tv_reset_setup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        boolean setup_over = SharedPreferencesUtil.getBoolean(this, ConstantValue.SETUP_OVER, false);
        if (setup_over){
            // 密码输入成功，并且四个导航界面均设置完成，才停留在设置完成后的功能列表
            setContentView(R.layout.activity_setupover);
            // 初始化UI
            initUI();
        }else {
            // 密码输入成功，若四个导航界面没有全部设置完成，则跳转到第一个导航界面
            Intent intent = new Intent(this, SetupOneActivity.class);
            startActivity(intent);
            finish();
        }
    }

    /**
     * 1.初始化UI
     */
    private void initUI() {
        tv_phone = findViewById(R.id.tv_phone);
        // 1.设置联系人号码
        String phone = SharedPreferencesUtil.getString(this, ConstantValue.CONTACT_PHONE, "");
       tv_phone.setText(phone);
        // 2.重新设置条目被点击
        tv_reset_setup = findViewById(R.id.tv_reset_setup);
        tv_reset_setup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(),SetupOneActivity.class);
                startActivity(intent);
                finish();
            }
        });
    }
}